package com.example.myapplication.Services;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.widget.Toast;

public class MyServices extends Service {
  private int bindingCount = 0;

  public class MyBinder extends Binder {

  }

  private final IBinder binder = new MyBinder();

  public IBinder onBind(Intent intent) {
    bindingCount++;
    return binder;
  }

  @Override public int onStartCommand(Intent intent, int flags, int startId) {
    return START_STICKY;
  }

  @Override public void onDestroy() {
    if (bindingCount <= 0) {
      return;
    }
    super.onDestroy();

    Toast.makeText(this, "Services destroyed", Toast.LENGTH_SHORT).show();

  }
  public MyServices getService() {
    return MyServices.this;
  }
  public void incrementBindingCount() {
    bindingCount++;
  }
  public void decrementBindingCount() {
    bindingCount--;
  }

  public int getBindingCount() {
    return bindingCount;
  }


}
